package com.carple.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.carple.dao.BoardDao;
import com.carple.dao.MemberDao;
import com.carple.dto.BoardComment;
import com.carple.dto.Member;

@WebServlet("/board/updatecomment.action")
public class BoardCommentUpdateServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		//1. BoardComment 객체 생성 -> 전송된 데이터를 읽어서 저장
		BoardComment comment = new BoardComment();
		comment.setCommentNo(
			Integer.parseInt(req.getParameter("commentno")));
		comment.setContent(req.getParameter("content"));

		//2. 데이터베이스 업데이트
		BoardDao dao = new BoardDao();
		dao.updateComment(comment);

		//3. boardview.action로 이동
		resp.sendRedirect(
			"view.action?" + 
			"boardno=" + req.getParameter("boardno") + 
			"&pageno=" + req.getParameter("pageno"));
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		doGet(req, resp);
	}
	
}




